package plp.functional2.primitive;

import java.util.Arrays;
import java.util.List;

import plp.expressions2.expression.Id;
import plp.expressions2.memory.AmbienteCompilacao;
import plp.expressions2.memory.AmbienteExecucao;
import plp.expressions2.memory.VariavelJaDeclaradaException;
import plp.expressions2.memory.VariavelNaoDeclaradaException;
import plp.functional2.expression.Aplicacao;

public class Spawn implements Primitiva {
	
	private List<Aplicacao> procAplicacoes;
	private Id idProcess;

	public void setIdProcess(Id idProcess) {
		this.idProcess = idProcess;
	}

	public Spawn(List<Aplicacao> procAplicacoes) {
		super();
		this.procAplicacoes = procAplicacoes;
	}
	
	public Spawn(Aplicacao ... procAplicacoes) {
		super();
		this.procAplicacoes = Arrays.asList(procAplicacoes);
	}

	public void executar(AmbienteExecucao amb)
			throws VariavelNaoDeclaradaException, VariavelJaDeclaradaException {

		for (Aplicacao proc : procAplicacoes) {
			proc.avaliar(amb);
		}
		return;
	}

	public boolean checaTipo(AmbienteCompilacao amb)
			throws VariavelNaoDeclaradaException, VariavelJaDeclaradaException {
		return true;
	}

	public List<Aplicacao> getProcAplicacoes() {
		return procAplicacoes;
	}

	public void setProcAplicacoes(List<Aplicacao> procAplicacoes) {
		this.procAplicacoes = procAplicacoes;
	}

}
